$(function(){
  $(".dislist").hide();
  
  $(".puuuuub").hover(function(){
    $(this).find(".dislist").stop(true,true);
    $(this).find(".dislist").slideDown();
  },function(){
    $(this).find(".dislist").stop(true,true);
    $(this).find(".dislist").slideUp();
  });

  $(".puuuuub li").hover(function(){
    $(this).addClass('hocer');
  },function(){
    $(this).removeClass('hocer');
  })

	//登陆弹窗
	$('#login_box , .login_boxb').on('click',function(){
    var furl = $(this).attr('furl');
    $(".furl").val(furl);
		var pageii = $.layer({
		    type: 1,
		    bgcolor: '',
		    title: false,
		   	area: ['auto', 'auto'],
		    border: [0], //去掉默认边框
		    //shade: [0], //去掉遮罩
		    closeBtn: [0, true], //去掉默认关闭按钮
		    shift: 'top', //从左动画弹出
		     page: {dom : '#log-box'}
		});
	});


	 $(".loginboxs").Validform({
            tiptype:0
      });
       
     $("#nowlogin").on('click',function(){
                var account = $("input[name='account']").val();
                var password = $("input[name='password']").val()
                var url =  $("input[name='url']").val();
               // alert(account);
                 if(account == ''){
                      layer.msg('用户名不能为空',1,-1);
                      return false;
                 };
                 if (password == '') {
                 	 layer.msg('密码不能为空',1,-1);
                      return false;
                 };
                 layer.load('登录中..', 3);
                  $.ajax({
                        type: "post",
                        url: "/User/newlogin",
                        data: {account:account,password:password},
                        dataType: "json",
                        success: function(data){
                         if (data.status=='1') {
                                layer.msg('登录成功', 1,1, function(){
                                    var furl = $(".furl").val();
                                     window.location.href= furl; 
                                });
                          }else{
                              layer.msg(data.content, 1,2);        
                          }
                        }      
                });
             })
        


 var hysoncate = $("#dcIndustry").children(".yy-selectcontent");
 var hysontxt =  $("#dcIndustry").find(".yy-selectlabeltxt");
 var sanjitxt =  $("#dcIndustrysan").find(".yy-selectlabeltxt");
 var sanji = $("#dcIndustrysan").find(".yy-selectcontent");

   /*发布行业信息 and 团体信息*/
   /*1父级菜单*/
   $("#dcPIndustry").click(function(){
    //alert(1);
    var thisul=$(this).children(".yy-selectcontent");
    var txt=$(this).children().children("span");
    if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};
    thisul.fadeIn(100);
    thisul.hover(function(){},function(){thisul.fadeOut("100");})
    thisul.find("li a").click(function(){
      //清空一下子栏目
     hysoncate.html('');
     //默认选中
     hysontxt.text('请选择');
     sanjitxt.text('请选择');
      var id = $(this).attr('data-value');
      if (id == 6) {
        $(".cspub").hide();
      }else{
        $(".cspub").show();
      }
      //ajax请求 查询二级分类
      $.ajax({
             type: "GET",
             url: "/Tiaozao/getSonHy",
             data: {pid:id},
             dataType: "json",
             success: function(data){
                     var obj = eval(data); 
                     var html = '<li><a href="javascript:;" class="txtellipsis active" data-value="">请选择</a> </li>';
                      $(obj).each(function(index) {
                          var val = obj[index]; 
                          html +='<li><a href="javascript:;" class="txtellipsis" data-value="'+val.id+'">'+val.title+'</a> </li>'
                          hysoncate.html(html);
                      })   
            }
         });



      txt.text($(this).text());
      thisul.hide();
      return false;
    });
  });

   /*2子菜单*/
   $("#dcIndustry").click(function(){
      var thisul=$(this).children(".yy-selectcontent");
      var txt=$(this).children().children("span");
      if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};
      thisul.fadeIn(100);
      thisul.hover(function(){},function(){thisul.fadeOut("100");})
      thisul.find("li a").click(function(){
      var id = $(this).attr('data-value');
      //写入表单
       sanjitxt.text('请选择');
       //ajax请求 查询二级分类
      $.ajax({
             type: "GET",
             url: "/Tiaozao/getthirdHy",
             data: {pid:id},
             dataType: "json",
             success: function(data){
                     var obj = eval(data); 
                     var html = '<li><a href="javascript:;" class="txtellipsis active" data-value="">请选择</a> </li>';
                      $(obj).each(function(index) {
                          var val = obj[index]; 
                          html +='<li><a href="javascript:;" class="txtellipsis" data-value="'+val.id+'">'+val.title+'</a> </li>'
                          sanji.html(html);
                      })   
            }
         });


      txt.text($(this).text());
     // $("#postfid").val(id);
      thisul.hide();
      return false;
    });
   })
  /*发布行业信息 and 团体信息*/

  /*3子菜单*/
   $("#dcIndustrysan").click(function(){
      var thisul=$(this).children(".yy-selectcontent");
      var txt=$(this).children().children("span");
      if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};
      thisul.fadeIn(100);
      thisul.hover(function(){},function(){thisul.fadeOut("100");})
      thisul.find("li a").click(function(){
      var id = $(this).attr('data-value');
      //写入表单
      txt.text($(this).text());
      $("#postfid").val(id);
      thisul.hide();
      return false;
    });
   })
  /*发布行业信息 and 团体信息*/

  $("#hyid").on('mouseover',function(){
      $(".soitemcontent").show();
  })

/**
 * [dzsoncate 地区]
 * @type {[type]}
 */
 var dzsoncate = $("#dzIndustry").children(".yy-selectcontent");
 var dzsontxt =  $("#dzIndustry").find(".yy-selectlabeltxt");
 var sandz =  $("#dzIndustrysan").find(".yy-selectlabeltxt");
 var dzsan = $("#dzIndustrysan").find(".yy-selectcontent");
 /*地区列表*/
   /*1父级菜单*/
   $("#dzPIndustry").click(function(){
    //alert(1);
    var thisul=$(this).children(".yy-selectcontent");
    var txt=$(this).children().children("span");
    if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};
    thisul.fadeIn(100);
    thisul.hover(function(){},function(){thisul.fadeOut("100");})
    thisul.find("li a").click(function(){
      //清空一下子栏目
     dzsoncate.html('');
     //默认选中
     dzsontxt.text('请选择');
     sandz.text('请选择');
      var id = $(this).attr('data-value');
      //ajax请求 查询二级分类
      $.ajax({
             type: "GET",
             url: "/Tiaozao/getsoncity",
             data: {pid:id},
             dataType: "json",
             success: function(data){
                     var obj = eval(data); 
                     var html = '<li><a href="javascript:;" class="txtellipsis active" data-value="">请选择</a> </li>';
                      $(obj).each(function(index) {
                          var val = obj[index]; 
                          html +='<li><a href="javascript:;" class="txtellipsis" data-value="'+val.id+'">'+val.name+'</a> </li>'
                          dzsoncate.html(html);
                      })   
            }
         });



      txt.text($(this).text());
      thisul.hide();
      return false;
    });
  });



/*2子菜单*/
   $("#dzIndustry").click(function(){
      var thisul=$(this).children(".yy-selectcontent");
      var txt=$(this).children().children("span");
      if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};
      thisul.fadeIn(100);
      thisul.hover(function(){},function(){thisul.fadeOut("100");})
      thisul.find("li a").click(function(){
      var id = $(this).attr('data-value');
      //写入表单
       sandz.text('请选择');
       //ajax请求 查询二级分类
      $.ajax({
             type: "GET",
             url: "/Tiaozao/getsoncity",
             data: {pid:id},
             dataType: "json",
             success: function(data){
                     var obj = eval(data); 
                     var html = '<li><a href="javascript:;" class="txtellipsis active" data-value="">请选择</a> </li>';
                      $(obj).each(function(index) {
                          var val = obj[index]; 
                          html +='<li><a href="javascript:;" class="txtellipsis" data-value="'+val.id+'">'+val.name+'</a> </li>'
                          dzsan.html(html);
                      })   
            }
         });


      txt.text($(this).text());
      $("#cityid").val(id);
      thisul.hide();
      return false;
    });
   })










 /*3子地区*/
   $("#dzIndustrysan").click(function(){
      var thisul=$(this).children(".yy-selectcontent");
      var txt=$(this).children().children("span");
      if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};
      thisul.fadeIn(100);
      thisul.hover(function(){},function(){thisul.fadeOut("100");})
      thisul.find("li a").click(function(){
      var id = $(this).attr('data-value');
     // alert(id);
      //写入表单
      txt.text($(this).text());
      $("#cityid").val(id);
      thisul.hide();
      return false;
    });
   })












});



 $(function() {
  var e = $("#rocket-to-top"),
  t = $(document).scrollTop(),
  n,
  r,
  i = !0;
  $(window).scroll(function() {
    var t = $(document).scrollTop();
    t == 0 ? e.css("background-position") == "0px 0px" ? e.fadeOut("slow") : i && (i = !1, $(".level-2").css("opacity", 1), e.delay(100).animate({
      marginTop: "-1000px"
    },
    "normal",
    function() {
      e.css({
        "margin-top": "-125px",
        display: "none"
      }),
      i = !0
    })) : e.fadeIn("slow")
  }),
  e.hover(function() {
    $(".level-2").stop(!0).animate({
      opacity: 1
    })
  },
  function() {
    $(".level-2").stop(!0).animate({
      opacity: 0
    })
  }),
  $(".level-3").click(function() {
    function t() {
      var t = e.css("background-position");
      if (e.css("display") == "none" || i == 0) {
        clearInterval(n),
        e.css("background-position", "0px 0px");
        return
      }
      switch (t){
      case "0px 0px":
        e.css("background-position", "-298px 0px");
        break;
      case "-298px 0px":
        e.css("background-position", "-447px 0px");
        break;
      case "-447px 0px":
        e.css("background-position", "-596px 0px");
        break;
      case "-596px 0px":
        e.css("background-position", "-745px 0px");
        break;
      case "-745px 0px":
        e.css("background-position", "-298px 0px");
      }
    }
    if (!i) return;
    n = setInterval(t, 50),
    $("html,body").animate({scrollTop: 0},"slow");
  });
});